
# Pleroma Comments

**Pleroma Comments** is a Pandoc filter that generates a comments section by fetching replies from the Fediverse (through Pleroma servers). 

Example: [https://antares.neocities.org/blog/pandoc-filter-pleroma-comments](https://antares.neocities.org/blog/pandoc-filter-pleroma-comments)

## Variables

The filter uses the variable `pleroma-urls` for input which can be defined in the manuscript's YAML header.

* `pleroma-urls`: a list of strings that should contain the URLs of the posts to source replies from.

The following two are optional.  If both are defined, then the script will download avatars and will not use hotlinks. 

1. (lua) `pleroma_avatar_path` = (yaml) `pleroma-avatar-path`: a string ending in `/`, the folder containing avatars as referenced by the web page (e.g `<img src="(pleroma-avatar-path)/avatar.png"/>`).
2. (lua) `pleroma_avatar_save_path` = (yaml) `pleroma-avatar-save-path`: a string ending in `/`, the folder in which avatars are downloaded to.

If multiple pages will be storing avatars in the same folder, create `config.lua` and assign the variables there. If a specific page will have its own directory for images, assign the variables in the manuscript's YAML header.

The filter exports variables that can be used in a Pandoc template.

* `pleroma-comments`: string, the full comments section rendered by the script.
* `pleroma-comments-count`: integer, the number of comments received by the script.
* `pleroma-has-comments`: boolean, whether or not there are comments available
* `pleroma`: table of strings, post IDs and their full URLs.

## Usage

In a Pandoc template, include the following to generate the entire comments section.

    $if(pleroma-urls)$
    <hr/>
    <h2 id="comments">Comments ($pleroma-comments-count$)</h2>
    <p>Reply to any of the bulleted links to leave a comment.</p>
    <ul>
        $for(pleroma)$
        <li><a href="$pleroma.link$">$pleroma.id$</a></li>
        $endfor$
    </ul>
    $pleroma-comments$
    $endif$

Add a link to jump to the comments section if there are any comments.

    $if(pleroma-has-comments)$
    <a href="#comments">View $pleroma-comments-count$ comment(s).</a>
    $endif$
